package cloud.take.off.config;

import cloud.take.off.enums.ModelEnum;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @description:
 * @author: gangan
 * @create: 2020-12-21 15:25
 */
@Configuration
@EnableSwagger2
//@Profile({"dev"})
public class SwaggerConfig {


    @Bean
    public Docket createSYSApi(){
        return new Docket(DocumentationType.SWAGGER_2).groupName(ModelEnum.SYS.getGroupName()).apiInfo(apiInfo())
                .select()
                .apis(Predicates.or(
                        RequestHandlerSelectors.basePackage(ModelEnum.SYS.getPackagePath())
                ))
                .paths(PathSelectors.any()).build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("系统管理 API Doc")
                .description("This is a restful api document of order.")
                .version("1.0")
                .build();
    }
}
